package com.xiaoguang.selecttext

import android.widget.TextView
import androidx.annotation.ColorInt
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import java.util.LinkedList

/**
 * author : wangbo
 * date   : 2023/11/22
 * desc   :
 */
const val DEFAULT_SELECTION_LENGTH = 2 // 选2个字节长度 例:表情属于2个字节
const val DEFAULT_SHOW_DURATION = 100L // 弹窗100毫秒延迟

class SelectBuilder(val mTextView: TextView) {
    var mCursorHandleColor = -0xec862a
    var mSelectedColor = -0x501e0c
    var mCursorHandleSizeInDp = 24f
    var mSelectAll = true
    var mSelectTextLength = DEFAULT_SELECTION_LENGTH
    var mScrollShow = true
    var mMagnifierShow = true
    var mPopDelay = DEFAULT_SHOW_DURATION

    /**
     * 选择游标颜色
     */
    fun setCursorHandleColor(@ColorInt cursorHandleColor: Int): SelectBuilder {
        mCursorHandleColor = cursorHandleColor
        return this
    }

    /**
     * 选择游标大小
     */
    fun setCursorHandleSizeInDp(cursorHandleSizeInDp: Float): SelectBuilder {
        mCursorHandleSizeInDp = cursorHandleSizeInDp
        return this
    }

    /**
     * 选中文本的颜色
     */
    fun setSelectedColor(@ColorInt selectedBgColor: Int): SelectBuilder {
        mSelectedColor = selectedBgColor
        return this
    }

    /**
     * 全选
     */
    fun setSelectAll(selectAll: Boolean): SelectBuilder {
        mSelectAll = selectAll
        return this
    }

    /**
     * 选择选择个数
     */
    fun setSelectTextLength(selectTextLength: Int): SelectBuilder {
        mSelectTextLength = selectTextLength
        return this
    }

    /**
     * 滑动依然显示弹窗
     */
    fun setScrollShow(scrollShow: Boolean): SelectBuilder {
        mScrollShow = scrollShow
        return this
    }

    /**
     * 显示放大镜
     */
    fun setMagnifierShow(magnifierShow: Boolean): SelectBuilder {
        mMagnifierShow = magnifierShow
        return this
    }

    /**
     * 弹窗延迟
     */
    fun setPopDelay(popDelay: Long): SelectBuilder {
        mPopDelay = popDelay
        return this
    }

    fun build(): SelectWorker {
        return SelectWorker(this)
    }
}